home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Apple Telecom / Remote Voice Watcher < prev   
Encoding:
Text File  |  1999-03-04  |  2.6 KB  |  116 lines  |  [TEXT/ToyS]

  1. -- User parameters
  2. property kasRemoteAppName : "◊ Voice Watcher"
  3. property sasMachine : "Kerr ◊ AKUA021 ◊ PM7166"
  4. property sasUser : "Beba"
  5. property sasPass : ""
  6. property sasZone : "*"
  7.  
  8. property sasCheckEvery : 45 -- How many seconds between checks
  9. property sasStatMax : 911 -- Silly number sets max of status bar we display.
  10.  
  11. -- Internal
  12. property sasStatus : ""
  13. property sasStatWind : 0
  14. property gasStatLoc : {0, 0}
  15. property sasStatVal : 0
  16. property sasStatAction : "…"
  17.  
  18. property sasLastQuit : 0
  19.  
  20.  
  21. on run
  22.     talk as user sasUser ¬
  23.         with password sasPass ¬
  24.         on server sasMachine ¬
  25.         in AppleTalk zone sasZone
  26.     
  27.     set sasLastQuit to 0
  28.     
  29.     set sasStatus to "I can't get no…"
  30.     
  31.     set sasStatWind to (display info titled sasMachine ¬
  32.         message sasStatus ¬
  33.         using font ¬
  34.         "Chicago" using size 12 ¬
  35.         using color (15 * (2 ^ 0)) ¬
  36.         located at gasStatLoc)
  37.     
  38.     --    set waitSecs to sasCheckEvery
  39.     --    repeat while (waitSecs > 0)
  40.     --        set waitSecs to idle {}
  41.     --        pause for waitSecs with seconds timing
  42.     --    end repeat
  43. end run
  44.  
  45.  
  46. on quit
  47.     if (sasLastQuit is not -1) then
  48.         asShowStatus("Quit, dammit!")
  49.         set gasStatLoc to screen location of ¬
  50.             (display info sasStatWind with disposal)
  51.     end if
  52.     
  53.     set sasLastQuit to -1
  54.     set sasStatWind to 0
  55.     
  56.     continue quit
  57. end quit
  58.  
  59.  
  60. on idle
  61.     if sasLastQuit is -1 then return 0
  62.     
  63.     if (sasLastQuit is 0) then
  64.         try
  65.             «event ÅkuaTalK» kasRemoteAppName given «class TSrv»:sasMachine, «class TZon»:sasZone ¬
  66.                 , «class TUsr»:sasUser, «class TPwd»:sasPass
  67.             set sasLastQuit to 1
  68.         on error errStr
  69.             asShowStatus(errStr)
  70.             beep
  71.             pause for 2 with seconds timing
  72.         end try
  73.     end if
  74.     
  75.     if sasLastQuit is 0 then
  76.         asShowAction("LOST COMMUNICATION!")
  77.         asShowStatus("LOST COMMUNICATION!")
  78.         asShowAction("…")
  79.     else
  80.         try
  81.             «event ÅkuaTalK» kasRemoteAppName given «class TSrv»:sasMachine, «class TZon»:sasZone ¬
  82.                 , «class TUsr»:sasUser, «class TPwd»:sasPass
  83.             
  84.             tell application kasRemoteAppName of machine sasMachine to get asStatus()
  85.             set remoteStat to the result
  86.             
  87.             set sasStatMax to barMax of remoteStat
  88.             set sasStatVal to barVal of remoteStat
  89.             asShowAction(action of remoteStat)
  90.             asShowStatus(Status of remoteStat)
  91.         on error
  92.             set sasLastQuit to 0
  93.         end try
  94.     end if
  95.     
  96.     return sasCheckEvery
  97. end idle
  98.  
  99.  
  100. on asShowStatus(Status)
  101.     if (Status is not sasStatus) then
  102.         set sasStatus to Status
  103.         set gasStatLoc to screen location of ¬
  104.             (display info sasStatWind message sasStatus)
  105.     end if
  106.     
  107.     set sasStatVal to sasStatVal + 1
  108.     if (sasStatVal > sasStatMax) then set sasStatVal to 1
  109. end asShowStatus
  110.  
  111.  
  112. on asShowAction(action)
  113.     display info sasStatWind message action at line 2
  114.     set sasStatAction to action
  115. end asShowAction
  116.